﻿namespace FSharpLib
open System
open System.Collections.Generic
open CSharpLib

type internal KujibikiProcesser2() =    
    interface IKujibikiProcesser with
        member this.GetPrize() =  KujibikiModule.GetPrize()

type internal SpecialKujibikiProcesser() =    
    interface IKujibikiProcesser with
        member this.GetPrize() =  KujibikiModule.GetPrizeFromXml()

type Kujibiki2 =
    val mutable private insertedCoin : int
    val mutable private kujiProc : IKujibikiProcesser
    val mutable private oneGameCoin : int

    new () =
         {insertedCoin = 0; kujiProc = new KujibikiProcesser2(); oneGameCoin = 100}
    internal new(proc) =
         {insertedCoin = 0; kujiProc = proc; oneGameCoin = 100}

    member this.OneGameCoin with get() = this.oneGameCoin
                                and set newVal = this.oneGameCoin <- newVal

    member this.InsertCoin(coin) = this.insertedCoin <- this.insertedCoin + coin

    member this.DrawLottery() = 
        if this.insertedCoin < this.OneGameCoin then
            raise <| Exception("一回" + this.OneGameCoin.ToString() + "コインが必要です。")
        this.insertedCoin <- this.insertedCoin - this.oneGameCoin
        this.kujiProc.GetPrize()

type SpecialKujibiki() =
    inherit Kujibiki2(new SpecialKujibikiProcesser())
